home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PsL Monthly 1993 December
/
PSL Monthly Shareware CD-ROM (December 1993).iso
/
prgmming
/
dos
/
c
/
arrays.exe
/
ARRAYS.INF
< prev
next >
Wrap
Text File
|
1991-11-02
|
3KB
|
55 lines
ARRAYS.INF dh:91-11-02
DEMONSTRATION OF POINTERS TO ARRAYS
-----------------------------------
The use of pointers to arrays is a baffling problem in C and C++ because
the C Language doesn't have any first-class notion of arrays. This can lead
to mysterious compiler complaints and execution behavior because the user's
conventional model of what arrays and the naming of arrays is about is
actually not supported directly in C Language. Arrays as other programming
languages may support them are actually obtained mainly by subterfuge in
C Language. The subterfuge is an extremely useful one until the programmer
is thrown up against a serious dissonance between intuitive assumptions and
what the C Language rules *really* are.
The two sample programs in this package provide simple demonstration of
one such area of dissonance -- trying to initialize and use a properly-defined
pointer to an array without getting error messages and possibly incorrect
behavior.
There are two modules: ARRAYS.C and ARRAYS.CPP. The first is in C Language,
the second is in C++ Version 2.0. They should be compiled separately for what
they reveal about arrays and pointers to arrays as usable objects (e.g., as
lvalues and rvalues as C Cognoscenti are prone to say).
For those who enjoy the Borland C++ 2.0 interactive environment, there is
an arrays.prj file that you can use to help with this. If you compile these
files from something like
C:>BC ARRAYS>PRJ
remember to go into the Options/Directory pull-down and correct the location
of libraries and include files to agree with your configuration setup.
These two little files were composed as the result of head-banging that
colleagues Barry Gombert, Bill Anderson and I went through trying to get
some array-pointing code to come out clean. If you stare at this and the
inscrutible error messages that go with it, maybe your head won't hurt so
much the next time you try to get array references to come out right!
-- Dennis E. Hamilton
1991 November 2
orcmid.roch817@xerox.com
70100.271@compuserve.com
CONTENTS:
ARRAYS C 1225 10-29-91 1:09p 1.00 ANSI C array-pointing behavior
ARRAYS CPP 1575 10-29-91 1:30p 1.01 C++ 2.0 array-pointing behavior
ARRAYS DES 331 11-02-91 4:12p NDOS descriptions for ARRAYS package
ARRAYS DSK 2489 10-29-91 7:15p Borland C++ Desktop for IDE use
ARRAYS PRJ 5316 10-29-91 7:15p Borland C++ Project for ARRAYS exploring